using System;
using System.Collections.Generic;
using Godot;

public partial class MyUtil
{           
    private static readonly Random random = new Random();

    public static List<AnimatedSprite2D> GetAnimatedSprite2Ds(Node node)
    {
        List<AnimatedSprite2D> results = new List<AnimatedSprite2D>();
        foreach(Node child in node.GetChildren())
        {
            if(child is AnimatedSprite2D animatedSprite2D)
                results.Add(animatedSprite2D);
            
            results.AddRange(GetAnimatedSprite2Ds(child));
        }

        return results;
    }

    public static float RangeRandom(float a, float b)
    {
        return (float)random.NextDouble()*(b-a)+a;
    }
}